function main() {
    const self = this;
    let litigantIdValue = this.cValue;
    const params = [{
        name: "litigantId",
        valueContent: litigantIdValue
    }];
    // ddcat 根据条件查询值
    api.DATA_SOURCE_EXECUTE("ds_mod:8fc68b45-c36a-4b1a-8bbc-c6db7b2ecbac", "ddcat", params, [], "").then(res => {
        debugger
        let litigantName = res.result[0].litigant_name;
        let litigantPhone = res.result[0].phone;
        let cardCode = res.result[0].card_code;
        let address = res.result[0].address;
        let sex = res.result[0].sex;
        self.$$("text_input_c1p7g2").cValue = litigantName;
        self.$$("text_input_1fqg4n").cValue = litigantPhone;
        self.$$("text_input_bnunoy").cValue = cardCode;
        self.$$("text_input_24gf3u").cValue = address;
        self.$$("radio_28vvt2").cValue = sex;
    }).catch(err => {
        console.log(err);
    });

    api.DATA_SOURCE_EXECUTE("ds_mod:467c2d03-36d1-41ea-b01e-5fc9c01eaea3", "ddcat", params, [], "").then(res => {
        debugger
        let case_violation_count = res.result[0].case_violation_count || 0;      // 案件违规次数
        let case_penalty_count = res.result[0].case_penalty_count || 0;          // 案件处罚次数
        let case_count = '';
        if (case_violation_count == 0 && case_penalty_count == 0) {
            case_count = '无相关违规/处罚记录';
        } else if (case_violation_count > 0 && case_penalty_count == 0) {
            case_count = case_violation_count + '次违规';
        } else if (case_violation_count == 0 && case_penalty_count > 0) {
            case_count = case_penalty_count + '次处罚';
        } else {
            case_count = case_violation_count + '次违规' + case_penalty_count + '次处罚';
        }

        if (case_violation_count > 0 || case_penalty_count > 0) {
            makeElementClickable(
                '#widget_list_picker_669p9a_csshandler_generate > div.mobile-tips',
                case_count,
                function () {
                    console.log('点击了违规/处罚记录');
                    openCaseSourceModal(self,litigantIdValue);
                }
            );
        } else {

            const element = document.querySelector('#widget_list_picker_669p9a_csshandler_generate > div.mobile-tips');
            if (element) {
                element.textContent = case_count;
                element.style.textAlign = "right";
                element.style.cursor = 'default';
            }
        }


    }).catch(err => {
        console.log(err);
    });

}

function makeElementClickable(selector, customText, clickHandler) {
    const element = document.querySelector(selector);

    if (!element) {
        console.error('未找到元素:', selector);
        return;
    }

    element.textContent = customText;
    element.style.cursor = 'pointer';
    element.style.userSelect = 'none';
    element.style.textAlign = "right";
    element.style.color = '#3388FF';

    element.addEventListener('click', clickHandler);
}

/**
 * 打开违规处罚列表页面
 */
function openCaseSourceModal(self,litigantId) {
    self.$router.push({
        name: "page-preview",
        query: {
            title: "违规记录",
            pageId: '1951213181004267520',
            litigant_id: litigantId,
            showHeader: this.$route.query.showHeader,
            pageTitle: "违规记录",
            linkTitle: '违规记录',
            showBackHeade: true,
            isFromAction: 1,
            _t: new Date().getTime() + ""
        }
    });
}

